<template>
  <view class="content">
    <view class="ml">
      <view
        class="mlb"
        @tap="to_listtwo(index, item.id)"
        v-for="(item, index) in items"
        :key="index"
      >
        <view class="mlbt">{{ item.sendTime }}</view>
        <view class="mlbc">
          <view class="mlbct">
            {{ item.title }}
          </view>
          <view class="mlbcf">
            立即查看 >
          </view>
        </view>
      </view>

      <!-- 	<view class="mlb">
				<view class="mlbt">7月10日 16:27</view>
				<view class="mlbc">
					<view class="mlbct">
						宋旋 上传了1个文件到【资料】
					</view>
					<view class="mlbcf">
						立即查看 >
					</view>
				</view>
			</view>
			
			<view class="mlb" @tap="to_more">
				<view class="mlbt">7月10日 16:27</view>
				<view class="mlbimg">
					<img src="../../static/img/fmt.png" class="mlbimgt"/>
					<view class="mlbimgf">
						7月新功能介绍
					</view>
				</view>
			</view>
			 -->
    </view>
    <view class="noc">
      <image src="../../static/img/ic_message_normal@2x.png"></image>
      <span>暂无消息</span>
    </view>
  </view>
</template>

<script>
import request from '@/common/request.js';
import { mapState } from 'vuex';

export default {
  data() {
    return {
      repeat_click: true,
      ashowpop: false,
      ashowpop_jrename: false,
      ashowpop_jdel: false,
      ashowpopT: false,
      bj: false,
      yd: false,
      biao: '全部',
      aitems: [
        { name: '全部', actived: true },
        { name: '本月', actived: false },
        { name: '3个月', actived: false },
        { name: '1年', actived: false },
        { name: '2年', actived: false },
      ],

      nodata: true,
      items: [],
      name: '',
      jtitle: '',
      nian: '',
      yue: '',
      re: '',
      week: '',
      today: '',
      projectName: '',
    };
  },

  onShow() {
    var date = new Date();
    var Y = date.getFullYear();
    var M =
      date.getMonth() + 1 < 10
        ? '0' + (date.getMonth() + 1)
        : date.getMonth() + 1;
    var D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
    var h = date.getDate();

    var now = new Date();
    var day = now.getDay();
    var weeks = new Array(
      '星期日',
      '星期一',
      '星期二',
      '星期三',
      '星期四',
      '星期五',
      '星期六',
    );
    var week = weeks[day];

    this.nian = Y;
    this.week = week;
    this.re = D;
    this.yue = M;

    this.today = Y + '-' + M + '-' + D;

    this.id = uni.getStorageSync('temp_data1').groupId;

    if (uni.getStorageSync('temp_data1').projectName) {
      this.projectName = uni.getStorageSync('temp_data1').projectName;
    }

    if (uni.getStorageSync('temp_data1').projectName) {
      this.projectName = uni.getStorageSync('temp_data1').projectName;
    } else {
      this.projectName = uni.getStorageSync('temp_data1').typeTxt;
    }

    // this.data_add("2020-01-01"+" 00:00",this.today+" 24:00");
    this.data_add();
  },

  computed: mapState(['forcedLogin', 'hasLogin', 'userName']),

  methods: {
    data_add(a, b) {
      // this.projectId = uni.getStorageSync('dqfull_name').id;

      // GET /v1/msg/{corpId}/list
      request({
        url: `/msg/group-msg/page/${this.id}`,
        method: 'GET',
        data: {
          size: 100,
          page: 1,
          // type: uni.getStorageSync('temp_data1').type,
          // startTime:a,
          // endTime:b,
        },

        success: res => {
          console.log('2项目列表信息', res);
          console.log(res.data.data);

          if (res.data.success == true) {
            if (res.data.data.rows) {
              this.items = res.data.data.rows;
              console.log(this.items);
              this.nodata = true;

              // var jdd = {};

              // jdd.type = 2;
              // request({
              //   url: `/msg/v1/msg/${
              //     uni.getStorageSync('user').corpBaseInfoResponse.id
              //   }/read/type`,
              //   method: 'POST',
              //   data: jdd,

              //   success: res => {
              //     console.log('标记已读', res);

              //     request({
              //       url: `/msg/group-msg/unread-cnt`,
              //       method: 'GET',

              //       success: res => {
              //         console.log('底部未读消息', res);
              //         if (res.data.success == true && res.data.data > 0) {
              //           uni.setTabBarBadge({
              //             index: 1,
              //             text: `${res.data.data}`,
              //           });
              //         }
              //       },
              //     });
              //   },
              // });
            } else {
              this.items = '';
              this.nodata = false;
            }
          } else {
            this.repeat_click = true;
            uni.showToast({
              title: res.data.msg,
              icon: 'none',
            });
          }
        },
        fail: () => {
          this.repeat_click = true;
          uni.showToast({
            title: '服务器开小差，请稍后~',
            icon: 'none',
          });
          return false;
        },
      });
    },

    // 跳转
    to_listtwo(a) {
      uni.setStorageSync('temp_data2', this.items[a]);
      console.log('aaaaa', this.items[a]);

      uni.navigateTo({
        url: '../msg/msg_more',
      });
    },

    navigateBack() {
      uni.navigateBack();
    },
  },
};
</script>

<style>
.ml {
  width: 100%;
  height: auto;
  display: block;
  float: left;
}
.mlb {
  width: 678rpx;
  height: auto;
  display: block;
  float: left;
  margin: 40rpx 36rpx 0;
}
.mlbt {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  margin: 0rpx 0 20rpx 0;
  text-align: center;
  font-size: 24rpx;
  color: #999999;
}
.mlbc {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  background: #ffffff;
  border-radius: 8rpx;
}
.mlbct {
  width: 630rpx;
  height: auto;
  display: block;
  float: left;
  font-size: 32rpx;
  line-height: 40rpx;
  color: #000000;
  margin: 24rpx;
}
.mlbcf {
  width: 630rpx;
  height: auto;
  display: block;
  float: left;
  font-size: 32rpx;
  line-height: 40rpx;
  color: #256aff;
  margin: 0 24rpx 24rpx;
}

.mlbimg {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  background: #ffffff;
  border-radius: 8rpx;
  overflow: hidden;
}
.mlbimgt {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  border-radius: 8rpx 8rpx 0 0;
}
.mlbimgf {
  width: 630rpx;
  height: auto;
  display: block;
  float: left;
  font-size: 32rpx;
  line-height: 40rpx;
  color: #000000;
  margin: 30rpx 24rpx;
}

.content {
  background: rgb(242, 242, 242);
}
.noc {
  width: 100%;
  height: auto;
  display: none;
  float: left;
  margin: 400rpx 0 0 0;
}
.noc image {
  width: 120rpx;
  height: 120rpx;
  display: block;
  float: left;
  margin: 0 315rpx 20rpx;
}
.noc span {
  width: auto;
  margin: 24rpx;
  height: auto;
  display: block;
  float: left;
  font-size: 32rpx;
  line-height: 40rpx;
  text-align: center;
  color: #999999;
}
</style>
